{% extends "expBase.html" %}

{% block extrahead %}
<script src="/site_media/scripts/disableRightClick.js" type="text/javascript" charset="utf-8"></script>
<script src="/site_media/scripts/jquery/jquery.pack.js" type="text/javascript" charset="utf-8"></script>
<script src="/site_media/scripts/jquery/jquery.form.js" type="text/javascript" charset="utf-8"></script>
<script src="/site_media/scripts/jquery/jquery.alphanumeric.pack.js" type="text/javascript" ></script>
<script src="/site_media/scripts/jquery/json.js" type="text/javascript" ></script>
<script src="/site_media/scripts/jquery/jquery.color.js" type="text/javascript" ></script>
<script src="/site_media/scripts/jquery/jquery.impromptu.1.0.js" type="text/javascript"></script>
<script src="/site_media/scripts/points.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
	// The toJSONString method is removed because otherwise, it shows up as a button with the
	// Impromptu jQuery plug in. See http://jquery.com/plugins/node/813
	// NOTE!: this means that toJSONString can't be used on objects! Not a problem at this
	// point, but this may not be tennnable in the future.
	delete(Object.prototype.toJSONString);

	// Code to run after the page is completely loaded.
	$(document).ready(function() {
		
		// exchangeParametersJSON contains the contents of the Nex component object
		exchangeParametersJSON = '{{exchangeParametersJSON|safe}}'.parseJSON();
		
		// These numbers are used to build strings e.g. p1x
		playerNumber = {{playerNumber}} + 1;
		opponentNumber = {{opponentNumber}} + 1;
		
		
		// Bind widget callbacks
		$("html").bind("widget_timer_event_timeout", function (event) {
			clearTimeout(timeout);
			$("#transactionSummaryMessage").html("You ran out of time.");
			$('#transactionSummaryOfferFromOpponent').css({display:"none"});
			$('#transactionSummaryOfferToOpponent').css({display:"none"});
			$("#transactionSummaryMessage").css({display:"block"});
			showScreen("transactionSummary");
		});
		
		//Init a points object
		points = new et_points();
		points.p1x = exchangeParametersJSON['p1x'];
		points.p2x = exchangeParametersJSON['p2x'];
		points.p1y = exchangeParametersJSON['p1y'];
		points.p2y = exchangeParametersJSON['p2y'];
		points.p1xMaxRequest = exchangeParametersJSON['p1xMaxRequest'];
		points.p2xMaxRequest = exchangeParametersJSON['p2xMaxRequest'];
		points.p1yMaxRequest = exchangeParametersJSON['p1yMaxRequest'];
		points.p2yMaxRequest = exchangeParametersJSON['p2yMaxRequest'];
		points.p1xValue_raw = exchangeParametersJSON['p1xValue'];
		points.p2xValue_raw = exchangeParametersJSON['p2xValue'];
		points.p1yValue_raw = exchangeParametersJSON['p1yValue'];
		points.p2yValue_raw = exchangeParametersJSON['p2yValue'];		
		
	    // bind the submit event of all forms on the page. The server response will be
		// delivered to the processFormResponse() function.
		$('form').ajaxForm({
			success: processFormResponse,
			beforeSubmit: function(){
				$(":submit").attr("disabled","disabled");
			}			
		});
				
		// The letter identity of the other player in the pairing. 
		opponentIdentity = "{{opponentIdentity}}";
		
		// Bind the input fields of the offerFormulation screen
		// Updates the "This deal would get you" number on the offerFormulation screen
		$('.offerFormulationInputs').numeric();
		$(".offerFormulationInputs").keyup(function(){
			offerPreview(false);
		});		
		$("#offerFormulationOfferUnit").change(function(){
			offerPreview(false);
		});
		$("#offerFormulationRequestUnit").change(function(){
			offerPreview(false);
		});
		
		// counter offer screen fields
		$('.counterOfferFormulationInputs').numeric();
		$(".counterOfferFormulationInputs").keyup(function(){
			offerPreview(true);
		});
		$("#counterOfferFormulationOfferUnit").change(function(){
			offerPreview(true);
		});
		$("#counterOfferFormulationRequestUnit").change(function(){
			offerPreview(true);
		});
		
		// Start polling server to check for opponents
		pollServer();
		
	});
	
	function offerPreview(counterOffer){
		points.offeredBy = "p" + playerNumber;
		$(".offerError").html("");
		$(".requestError").html("");		
		if(counterOffer){
			points.offer = $("#counterOfferFormulationOffer").val();
			points.request = $("#counterOfferFormulationRequest").val();
			points.offerUnit = $("#counterOfferFormulationOfferUnit").val();
			points.requestUnit = $("#counterOfferFormulationRequestUnit").val();
		} else {
			points.offer = $("#offerFormulationOffer").val();
			points.request = $("#offerFormulationRequest").val();
			points.offerUnit = $("#offerFormulationOfferUnit").val();
			points.requestUnit = $("#offerFormulationRequestUnit").val();
		}
		
		// enable the offer and counter offer submit buttons if an offer is valid
		if(points.offer.length > 0 && points.request.length > 0){
			$("#offerFormulationOfferSubmit").removeAttr("disabled");
			$("#counterOfferFormulationSubmit").removeAttr("disabled");
		} else {
			$("#offerFormulationOfferSubmit").attr("disabled","disabled");
			$("#counterOfferFormulationSubmit").attr("disabled","disabled");
		}
		
		response = points.calculatePoints();
		if(!response.error){
			$(".pointsPreview").html(String(response[points.offeredBy +'Points_justExchange']));
		} else {
			$(":submit").attr("disabled","disabled");
			$(".pointsPreview").html("--");
			switch(response.errorMsg){
				case "Insufficient funds for offer":
					$(".offerError").html("You don't have enough " + points.offerUnit + ".");
					break;
				case "Exceeded max request":
					$(".requestError").html("You cannot request that many " + points.requestUnit + ".");
					break;
				default:
					alert(response.errorMsg);
			}
		}
	}
	
	// Each screen contains a form that submits the user's input to the server.
	// This function processes the server's response and updates the page accordingly.
	function processFormResponse(responseText){
		// Reenable the submit buttons
		$(":submit").removeAttr("disabled");
		// but don't reenable the offer and counter offer submit buttons
		$("#counterOfferFormulationSubmit").attr("disabled","disabled");
		$("#offerFormulationOfferSubmit").attr("disabled","disabled");
		
		// responseText the response returned by the server. It is JSON formatted.
		// Note: parseJSON() is not jQuery, rather it's in json.js from json.org
		responseJSON = responseText.parseJSON();
		examineJSON(responseJSON);
		return;
	}
	
	// This function polls the server with two AJAX requests. The first grabs the location of the current poll process
	// and the second polls the URL resource.
	function pollServer(){
		$.ajax({	url: "/nex/getPollURL/",
					dataType: "json", 
					success: function(pollServer){
						if(pollServer['pollURL'] == "None"){
							setTimeout("pollServer()", 1000);
						} else {
							$.ajax({	url: pollServer['pollURL'], 
										dataType: "json", 
										success: function(responseJSON){
											examineJSON(responseJSON);
											setTimeout("pollServer()", 1000);
										}
									});
						}
					}
				});
	}
	
	function showOfferPoints(offer, direction) {
		points.offer = offer['offer'];
		points.request = offer['request'];
		points.offerUnit = offer['offerUnit'];
		points.requestUnit = offer['requestUnit'];
		
		if(direction == "incoming"){
			$('.currentGain').html(String(offer['offer']));
			$('.currentGainUnit').html(String(offer['offerUnit']).toUpperCase());
			$('.currentLoss').html(String(offer['request']));
			$('.currentLossUnit').html(String(offer['requestUnit']).toUpperCase());
			points.offeredBy = "p" + opponentNumber;
		} else {
			$('.currentGain').html(String(offer['request']));
			$('.currentGainUnit').html(String(offer['requestUnit']).toUpperCase());
			$('.currentLoss').html(String(offer['offer']));
			$('.currentLossUnit').html(String(offer['offerUnit']).toUpperCase());
			points.offeredBy = "p" + playerNumber;
		}
		response = points.calculatePoints();
		if(!response.error){
			$(".currentPoints").html(String(response["p" + playerNumber +'Points_justExchange']));
			$("#transactionSummaryPoints").val(String(response["p" + playerNumber +'Points']));
		} else {
			alert(response.errorMsg);
		}
	}
	
	function examineJSON(responseJSON){		
		if(responseJSON['redirect']){
			window.location = responseJSON['redirect'];
		}
		if(responseJSON['startTimer']){
			$("html").trigger("widget_timer_event_startTimer");
		}
		if(responseJSON['stopTimer']){
			$("html").trigger("widget_timer_event_stopTimer");
		}
		if(responseJSON['restartTimer']){
			$("html").trigger("widget_timer_event_resetTimer");
		}
		if(responseJSON['showTime']){
			$("html").trigger("widget_timer_event_scheduleTimer", [responseJSON['showTime']]);
		}
		if(responseJSON['incomingOffer']){
			showOfferPoints(responseJSON['incomingOffer'], "incoming");
		}
		if(responseJSON['outgoingOffer']){
			showOfferPoints(responseJSON['outgoingOffer'], "outgoing");
		}
		if(responseJSON['transactionType']){
			$('.transactionSummaryMessages').css({display:"none"});
			$('#transactionSummary_' + responseJSON['transactionType']).css({display:"block"});
		}
		if(responseJSON['nonBindingOfferType']){
			$('#nonBindingConfirmationOfferFromOpponent').css({display:"none"});
			$('#nonBindingConfirmationOfferToOpponent').css({display:"none"});
			$('#nonBindingConfirmation' + responseJSON['nonBindingOfferType']).css({display:"block"});
		}
		if(responseJSON['setX'] >= 0){
			setTimeout('setXandY("X","' + responseJSON["setX"] + '")', 0);
		}
		if(responseJSON['setY'] >= 0){
			setTimeout('setXandY("Y","' + responseJSON["setY"] + '")', 500);
		}
		if(responseJSON['initBank'] >= 0){
			$("html").trigger("widget_bank_event_set", [responseJSON['initBank']]);
		}
		if(responseJSON['updateBank'] >= 0){
			oldPoints = responseJSON['updateBank'];
			currentPoints = points.lastResponse["p" + playerNumber +'Points'];
			updatedPoints = parseInt(oldPoints) + parseInt(currentPoints);
			setTimeout('$("html").trigger("widget_bank_event_set", [updatedPoints])', 1000);
		}
		if(responseJSON['insufficientFunds'] == true){
			$('#incomingOfferInsufficientFunds').css({display:"block"});
			$('#incomingOfferAcceptButton').attr({disabled:"disabled"});
		} else {
			$('#incomingOfferInsufficientFunds').css({display:"none"});
			$('#incomingOfferAcceptButton').removeAttr("disabled");
		}
		if(responseJSON['resetFormulationForms']){
			$(".offerError").html("");
			$(".requestError").html("");
			$(".pointsPreview").html("--");
			$("#counterOfferFormulationOffer").val("");
			$("#counterOfferFormulationRequest").val("");
			$("#counterOfferFormulationOfferUnit").val("x");
			$("#counterOfferFormulationRequestUnit").val("y");
			$("#offerFormulationOffer").val("");
			$("#offerFormulationRequest").val("");
			$("#offerFormulationOfferUnit").val("x");
			$("#offerFormulationRequestUnit").val("y");
			$("#counterOfferFormulationSubmit").attr("disabled","disabled");
			$("#offerFormulationOfferSubmit").attr("disabled","disabled");
		}
		if(responseJSON['showDialog']){
			showDialog(responseJSON['showDialog']);
		}
		if(responseJSON['showScreen']){
			showScreen(responseJSON['showScreen']);
		}
	}
	
	function setXandY(letter, amount){
		letter = letter.toUpperCase();
		$('#available' + letter).html(amount);
		$("#available" + letter).css("backgroundColor","yellow");
		$("#available" + letter).animate({ backgroundColor: "#FFF" }, {queue:false, duration:2000});
	}
	
	// This function displays only the specified screen. screenName should be the the div ID
	// of the desired screen.
	function showScreen(screenName){
		// Turn off all the screens
		$(".exchangeScreen").css("display", "none");
		// turn on the specified screen
		$("#" + screenName).css("display", "block");
		return;
	}
	
	// These functions set up and trigger the appropriate dialog screens
	function showDialog(dialogName){
		if(dialogName == "incomingOffer"){
			msg  = "You've received an offer from player " + opponentIdentity;
			$.prompt(msg, { buttons: { "View Offer": "View Offer", "Do Not View Offer": "Do Not View Offer" }, 
							callback: incomingOfferDialogAction, 
							container: "html",
							opacity: 0.8,
							show:"fadeIn",
							overlayspeed: 0,
							promptspeed: 0
							});	
		}
		if(dialogName == "offerDeclined"){
			msg  = "Player " + opponentIdentity + " chose not to look at your offer.";
			$.prompt(msg, { callback: offerDeclinedDialogAction, 
							container: "html",
							opacity: 0.8,
							show:"fadeIn",
							overlayspeed: 0,
							promptspeed: 0
							});	
		}
	}
	
	function incomingOfferDialogAction(buttonValue, msg){
		if (buttonValue == "View Offer") {
			// Check if the transactionSummary screen is showing. If so
			// the other player must have canceled the offer while waiting.
			if ($("#transactionSummary").css("display") != "block") {
				showScreen("incomingOffer");
			}
		} else {
			// Send message that the player chose not to see the offer
			$.ajax({url: "/nex/incomingOfferDeclinedToView/", 
					dataType: "json", 
					success: 	function(responseJSON){
									examineJSON(responseJSON);
								}
			});
		}
	}
	function offerDeclinedDialogAction(buttonValue, msg){
		showScreen("offerFormulation");
	}

</script>

{% endblock %}

{% block actionArea %}
<div id="checkForOpponent" class="exchangeScreen">
	<br/><br/><br/><br/>
	<h1>You are about to exchange with Player {{opponentIdentity}}</h1>
	<br/><br/><br/><br/>
	<h3>Please wait...</h3>
	<img src="/site_media/images/indicatorMed.gif" width="32" height="32" alt="IndicatorMed">
</div>
<div id="makeOfferButton" style="display:none;" class="exchangeScreen">
	<br/><br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/><br/><br/><br/><br/>
	<form action="/nex/makeOfferButton/" method="post" accept-charset="utf-8">
		<input type="submit" name="makeOfferSubmit" value="Click to Begin" class="buttonBig"/>
	</form>
</div>
<div id="offerFormulation" style="display:none;" class="exchangeScreen">
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<form action="/nex/offerFormulation/" method="post" accept-charset="utf-8" autocomplete="off">
		<p>What will you give?</p>
		<p>
			<input type="text" name="offerFormulationOffer" id="offerFormulationOffer" class="offerFormulationInputs" value="" size="4" maxlength="4"/>
			<select name="offerFormulationOfferUnit" id="offerFormulationOfferUnit">
				<option>x</option>
				<option>y</option>
			</select>
			<span id="offerFormulationOfferError" class="offerError"></span>
		</p>
		<p>What do you want in return?</p>
		<p>
			<input type="text" name="offerFormulationRequest" id="offerFormulationRequest" class="offerFormulationInputs" value="" size="4" maxlength="4"/>
			<select name="offerFormulationRequestUnit" id="offerFormulationRequestUnit">
				<option>y</option>
				<option>x</option>
			</select>
			<span id="offerFormulationRequestError" class="requestError"></span>
		</p>
		<br/>
		<p>This deal would get you: <b><span class="pointsPreview">--</span></b> points</p>
		<input type="submit" name="offerFormulationOfferSubmit" value="Offer" class="buttonBig" id="offerFormulationOfferSubmit" disabled="disabled"/>
	</form>
</div>
<div id="counterOfferFormulation" style="display:none;" class="exchangeScreen">
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<form action="/nex/counterOfferFormulation/" method="post" accept-charset="utf-8" autocomplete="off">
		<p>
			Player {{opponentIdentity}} offered you 
			<strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s 
			 for 
			<strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s. 
			<br/>This deal would get you: <b><span class="currentPoints">-</span></b> point(s).
		</p>
		<p>Enter your counter offer below.</p>
		<p>What will you give?</p>
		<p>
			<input type="text" name="counterOfferFormulationOffer" id="counterOfferFormulationOffer" class="counterOfferFormulationInputs" value="" size="4" maxlength="4"/>
			<select name="counterOfferFormulationOfferUnit" id="counterOfferFormulationOfferUnit">
				<option>x</option>
				<option>y</option>
			</select>
			<span id="counterOfferFormulationOfferError" class="offerError"></span>
		</p>
		<p>What do you want in return?</p>
		<p>
			<input type="text" name="counterOfferFormulationRequest" id="counterOfferFormulationRequest" class="counterOfferFormulationInputs" value="" size="4" maxlength="4"/>
			<select name="counterOfferFormulationRequestUnit" id="counterOfferFormulationRequestUnit">
				<option>y</option>
				<option>x</option>
			</select>
			<span id="counterOfferFormulationRequestError" class="requestError"></span>
		</p>
		<br/>
		<p>This deal would get you: <b><span class="pointsPreview">--</span></b> points</p>
		<input type="submit" name="counterOfferFormulationSubmit" value="Cancel" class="buttonBig"/>
		<input type="submit" name="counterOfferFormulationSubmit" value="Counter Offer" class="buttonBig" id="counterOfferFormulationSubmit" disabled="disabled"/>
	</form>
</div>
<div id="waitingScreen" style="display:none;" class="exchangeScreen">
	<br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/>
	<h3>Please wait for player {{opponentIdentity}}</h3>
	<img src="/site_media/images/indicatorMed.gif" width="32" height="32" alt="IndicatorMed">
	<!-- Commented out because canceling is not fully supported yet. 
		<p>
		<form action="/nex/waitingScreen/" method="post" accept-charset="utf-8">
			<input type="submit" name="waitingScreenCancel" value="Cancel" class="buttonBig"/>
		</form>
	</p> -->
</div>
<div id="confirmCancel" style="display:none;" class="exchangeScreen">
	<br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/><br/>
	<p>Are you sure you want to cancel your offer?</p>
	<p>
		<form action="/nex/confirmCancel/" method="post" accept-charset="utf-8">
			<input type="submit" name="confirmCancelSubmit" value="No" class="buttonBig"/> 
			<input type="submit" name="confirmCancelSubmit" value="Yes" class="buttonBig"/>
		</form>
	</p>
</div>
<div id="incomingOffer" style="display:none;" class="exchangeScreen">
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/><br/><br/>
	<p>Player {{opponentIdentity}} offered you 
		<strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s 
		 for 
		<strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s. 
	</p>
	<p>This deal would get you: <b><span class="currentPoints">-</span></b> points</p>
	<div id="incomingOfferInsufficientFunds" style="display:none;">You don't have enough to fulfill Player {{opponentIdentity}}'s request!</div>
	<p>
		<form action="/nex/incomingOffer/" method="post" accept-charset="utf-8">
			<input type="submit" name="incomingOfferSubmit" value="Accept" class="buttonBig" id="incomingOfferAcceptButton"/> 
			<input type="submit" name="incomingOfferSubmit" value="Counter Offer" class="buttonBig"/>
			<input type="submit" name="incomingOfferSubmit" value="End Round" class="buttonBig"/>
		</form>	
	</p>
</div>
<div id="confirmEndRound" style="display:none;" class="exchangeScreen">
	<br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/><br/>
	<p>Are you sure you want to end this round of exchange?</p>
	<p>
		<form action="/nex/confirmEndRound/" method="post" accept-charset="utf-8">
			<input type="submit" name="confirmEndRoundSubmit" value="No" class="buttonBig"/> 
			<input type="submit" name="confirmEndRoundSubmit" value="Yes" class="buttonBig"/>
		</form>	
	</p>
</div>
<div id="nonBindingConfirmation" style="display:none;" class="exchangeScreen">
		<br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/>	
	<div id="nonBindingConfirmationOfferFromOpponent" style="display:none;">
		You accepted player {{opponentIdentity}}'s offer of <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s 
		in exchange for <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.
		<br/><br/>
		Do you want to follow through on your part of the deal<br/> 
		and give <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s 
		to player {{opponentIdentity}}?
	</div>
	<div id="nonBindingConfirmationOfferToOpponent" style="display:none;">
		You accepted player {{opponentIdentity}}'s offer of <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s 
		in exchange for <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.
		<br/><br/>
		Do you want to follow through on your part of the deal<br/> 
		and give <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s 
		to player {{opponentIdentity}}?
	</div>
	<br/>
	<p>
		<form action="/nex/nonBindingConfirmation/" method="post" accept-charset="utf-8">
			<input type="submit" name="nonBindingConfirmationSubmit" value="No" class="buttonBig"/> 
			<input type="submit" name="nonBindingConfirmationSubmit" value="Yes" class="buttonBig"/>
		</form>
	</p>
</div>
<div id="nonBindingWaitingScreen" style="display:none;" class="exchangeScreen">
	<br/><br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/>
	<h3>Please wait for player {{opponentIdentity}}</h3>
	<img src="/site_media/images/indicatorMed.gif" width="32" height="32" alt="IndicatorMed">
</div>
<div id="transactionSummary" style="display:none;" class="exchangeScreen">
	<br/><br/>
	<h1>Exchanging with Player {{opponentIdentity}}</h1>
	<br/><br/>
	<div id="transactionSummary_youEndedTheRound" class="transactionSummaryMessages">
		You ended the round.
	</div>
	<div id="transactionSummary_opponentEndedRound" class="transactionSummaryMessages">
		After seeing your offer, the other player ended the round.
	</div>
	<div id="transactionSummary_youCanceledOffer" class="transactionSummaryMessages">
		You canceled your offer.
	</div>
	<div id="transactionSummary_opponentCanceledOffer" class="transactionSummaryMessages">
		The other player canceled the offer before you responded.
	</div>
	<div id="transactionSummary_youAccepted" class="transactionSummaryMessages">
		You accepted player {{opponentIdentity}}'s offer. Player {{opponentIdentity}} offered <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>(s) 
		in exchange for <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>(s).
		<br/>
		You received <strong><span class="currentPoints">-</span></strong>s 
		points for this deal.
	</div>
	<div id="transactionSummary_opponentAccepted" class="transactionSummaryMessages">
		Player {{opponentIdentity}} accepted your offer. You offered <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>(s)  
		in exchange for <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>(s).
		<br/>
		You received <strong><span class="currentPoints">-</span></strong>s 
		points for this deal.
	</div>
	<div id="transactionSummary_youRenegedOpponentReneged" class="transactionSummaryMessages">
		<p>Player {{opponentIdentity}} chose not to follow through on the deal
			and did NOT give you <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s.</p>
		<p>You chose not to follow through on the deal
			and did NOT give player {{opponentIdentity}} <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.</p>
	</div>
	<div id="transactionSummary_youRenegedOpponentFollowedThrough" class="transactionSummaryMessages">
		<p>Player {{opponentIdentity}} followed through on the deal 
			and gave you <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s.</p>
		<p>You chose not to follow through on the deal
			and did NOT give player {{opponentIdentity}} <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.</p>
	</div>
	<div id="transactionSummary_youFollowedThroughOpponentReneged" class="transactionSummaryMessages">
		<p>Player {{opponentIdentity}} chose not to follow through on the deal
			and did NOT give you <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s.</p>
		<p>You followed through on the deal
			and gave player {{opponentIdentity}} <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.</p>
	</div>
	<div id="transactionSummary_youFollowedThroughOpponentFollowedThrough" class="transactionSummaryMessages">
		<p>Player {{opponentIdentity}} followed through on the deal 
			and gave you <strong><span class="currentGain">-</span> <span class="currentGainUnit">-</span></strong>s.</p>
		<p>You followed through on the deal
			and gave player {{opponentIdentity}} <strong><span class="currentLoss">-</span> <span class="currentLossUnit">-</span></strong>s.</p>
	</div>
	<p>
		<form action="/nex/transactionSummary/" method="post" accept-charset="utf-8">
			<input type="submit" name="transactionSummarySubmit" value="Continue" class="buttonBig"/>
			<input type="hidden" name="transactionSummaryPoints" value="-" id="transactionSummaryPoints">
		</form>
	</p>
</div>
<div id="nextRoundCountdown" style="display:none;" class="exchangeScreen">
	<h1>Starting next round shortly</h1>
	<img src="/site_media/images/indicatorMed.gif" width="32" height="32" alt="IndicatorMed">
</div>
{% endblock %}

{% block rightCol %}
	{{widgets|safe}}
{% endblock %}

{% block bottomBar %}

<div id="currentXBox">
	<p>Total X</p>
	<div id="availableX" class="largePoints">-</div>
	{% if showXYValue %}
		<div id="valueOfEachX">
			Each X is worth {{xValue}} points
		</div>	
	{% endif %}

</div>
<div id="currentYBox">
	<p>Total Y</p>
	<div id="availableY" class="largePoints">-</div>
	{% if showXYValue %}
	<div id="valueOfEachX">
		Each Y is worth {{yValue}} points
	</div>	
	{% endif %}
</div>

{% endblock %}